#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
    int data;
    node *next;
}*head, *p, *r;
int n, x;
int main()
{
    scanf("%d", &n);
    int a;
    head = new node; head -> next = NULL;
    r = head;
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d", &a);
        p = new node;
        p -> data = a;
        p -> next = NULL;
        r -> next = p;
        r = p;
    }
    p = head;
    scanf("%d", &x);
    while(p != NULL)
    {
        node *s = p -> next;
        if(s && s -> data == x)
        {
            p -> next = p -> next -> next;
            free(s);
        }
        else p = p -> next;
    }
    p = head -> next;
    while(p -> next != NULL)
    {
        cout<<p -> data<<" ";
        p = p -> next;
    }
    cout<<p -> data;
}
